#include "GfxEngine.h"
#include <iterator>

GfxEngine::GfxEngine()
{
    this->image_vector = vector<Image*>();
    vector<int> v;
}
GfxEngine::~GfxEngine()
{
    //unload all surfaces
}

void GfxEngine::add_image(Image* img)
{
    this->image_vector.push_back(img);
}
void GfxEngine::delete_image(Image* img)
{
    vector<Image*>::iterator it = this->image_vector.begin();
    while (it != this->image_vector.end())
    {
        if (*it == img)
            break;
        else
            ++it;
    }
    this->image_vector.erase(it);
}

bool GfxEngine::load()
{
    vector<Image*>::iterator it = this->image_vector.begin();
    while (it != this->image_vector.end())
    {
        if ((*it)->load() == false)
            return false; //loading failed, game exiting..
        ++it;
    }
    return true;
}

void GfxEngine::draw(SDL_Surface* screen)
{
    vector<Image*>::iterator it = this->image_vector.begin();
    while (it != this->image_vector.end())
    {
        (*it)->draw(screen);
        ++it;
    }
}
